package edu.service.impl;

import edu.repository.BaseCourseRepository;
import edu.service.BaseCourseService;
import edu.vo.BaseCourse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class BaseCourseServiceImpl implements BaseCourseService {

    @Autowired
    private BaseCourseRepository baseCourseRepository;

    @Override
    public BaseCourse saveBaseCourse(BaseCourse baseCourse) {
        return baseCourseRepository.save(baseCourse);
    }

    @Override
    public Optional<BaseCourse> getBaseCourseById(Integer id) {
        return baseCourseRepository.findById(id);
    }

    @Override
    public List<BaseCourse> getAllBaseCourses() {
        return baseCourseRepository.findAll();
    }

    @Override
    public void deleteBaseCourseById(Integer id) {
        baseCourseRepository.deleteById(id);
    }

    @Override
    public BaseCourse updateBaseCourse(BaseCourse baseCourse) {
        return baseCourseRepository.save(baseCourse);
    }
}